package org.nanotek.dao.spring.impl;

import java.util.List;

import org.nanotek.beans.ArtistCredit;
import org.nanotek.beans.ArtistCreditName;
import org.nanotek.beans.ArtistName;
import org.nanotek.dao.spring.ArtistCreditDAO;

@SuppressWarnings({ "unchecked", "serial" })
public class ArtistCreditDAOImpl extends GeneralPurposeDAO implements ArtistCreditDAO<ArtistCredit>{

	public ArtistCredit findById (Long id)
	{ 
		return (ArtistCredit) getHibernateTemplate().get(clazz, id);
	}

	@Override
	public List<ArtistCredit> findByKeyId(Long nameId) {
		// TODO Auto-generated method stub
		ArtistCredit artistCredit = new ArtistCredit();
		artistCredit.setArtistCreditId(nameId);
		return  ((List<ArtistCredit>) getHibernateTemplate().
				findByExample(artistCredit));
	}


	@Override
	public List<ArtistCredit> findArtistCreditByArtist(ArtistName artistName) {
		String jpql = "Select ac from ArtistCredit ac where ac.artistCreditId = ?"; 
		return getHibernateTemplate().find(jpql , artistName.getMbid());
	}

	@Override
	public List<ArtistCredit> findCreditsByArtistCreditName(
			ArtistCreditName artistCreditName) {
		String jpql = "Select ac from ArtistCredit ac where ac.artistCreditId = ?"; 
		return getHibernateTemplate().find(jpql , artistCreditName.getArtistCredit());
	}

}
